package com.gxd.service.impl;

import com.gxd.dao.UserDao;
import com.gxd.dao.impl.UserDaoImpl;
import com.gxd.domain.User;
import com.gxd.service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
    @Override
    public boolean checkUserName(String username) {
        long count =userDao.selectByName(username);

        return count>0;
    }

    @Override
    public boolean add(String username, String password, String email, String gender) {
        User user = new User(0,username,password,email,gender,1,1,"");
        int count =userDao.insert(user);
        return count==1;
    }

    @Override
    public User login(String username, String password) {
        return userDao.selectByUsernameAndPassword(username,password);
    }

    @Override
    public User findAll(int uid) {
        return userDao.findAll(uid);
    }


}
